home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performStitchSurfacePoints.m < prev    next >
Encoding:
Text File  |  2003-07-17  |  9.1 KB  |  365 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  April 29, 1997
  22. //  Author:         ramesh 
  23. //
  24. //  Description:
  25. //      This script is defines the option box to stitchSurface points
  26. //        together.
  27. //
  28.  
  29.  
  30. //
  31. //  Procedure Name:
  32. //      setOptionVars
  33. //
  34. //  Description:
  35. //        Initialize the option values.
  36. //
  37. //  Input Arguments:
  38. //        Whether to set the options to default values.
  39. //
  40. //  Return Value:
  41. //      None.
  42. //
  43. proc setOptionVars(int $forceFactorySettings)
  44. {
  45.     stitchSurfacePointsSetOptionVars( $forceFactorySettings );
  46. }
  47.  
  48. //
  49. //  Procedure Name:
  50. //      stitchSurfacePointsSetup
  51. //
  52. //  Description:
  53. //        Update the state of the option box UI to reflect the option values.
  54. //
  55. //  Input Arguments:
  56. //      parent  - Top level parent layout of the option box UI.
  57. //                Required so that UI object names can be 
  58. //                successfully resolved.
  59. //
  60. //        forceFactorySettings - Whether the option values should be set to
  61. //                             default values.
  62. //
  63. //  Return Value:
  64. //      None.
  65. //
  66.  
  67. global proc stitchSurfacePointsSetup(string $parent, int $forceFactorySettings)
  68. {
  69.     //    Retrieve the option settings
  70.     //
  71.     setOptionVars($forceFactorySettings);
  72.  
  73.     setParent $parent;
  74.  
  75.     //    Query the optionVar's and set the values into the controls.
  76.  
  77.     // Query the optionVar's and set the values into the controls
  78.     //
  79.     int $keepOriginal = `optionVar -query stitchSurfacePointsKeepOriginal`;
  80.     int $ewt = `optionVar -query stitchSurfacePointsEqualWts`;
  81.     int $cascade = `optionVar -query stitchSurfacePointsCascade`;
  82.  
  83.     checkBoxGrp -edit -value1 $keepOriginal keepOriginalCheckBox;
  84.     checkBoxGrp -edit -value1 $ewt stitchSrfPtsEqualWtsCheckBox;
  85.     checkBoxGrp -edit -value1 $cascade stitchSrfPtsCascadeCheckBox;
  86. }
  87.  
  88. //
  89. //  Procedure Name:
  90. //      stitchSurfacePointsCallback
  91. //
  92. //  Description:
  93. //        Update the option values with the current state of the option box UI.
  94. //
  95. //  Input Arguments:
  96. //      parent - Top level parent layout of the option box UI.  Required so
  97. //               that UI object names can be successfully resolved.
  98. //
  99. //        doIt   - Whether the command should execute.
  100. //
  101. //  Return Value:
  102. //      None.
  103. //
  104.  
  105. global proc stitchSurfacePointsCallback(string $parent, int $doIt)
  106. {
  107.     setParent $parent;
  108.  
  109.     // Set the optionVar's from the current control values, and then perform 
  110.     // the command
  111.     //
  112.     int $keepOrig = `checkBoxGrp -query -v1 keepOriginalCheckBox`;
  113.     optionVar -intValue stitchSurfacePointsKeepOriginal $keepOrig;
  114.  
  115.     int $equalWts = `checkBoxGrp -q -value1 stitchSrfPtsEqualWtsCheckBox`;
  116.     optionVar -intValue stitchSurfacePointsEqualWts $equalWts;
  117.  
  118.     int $cascade = `checkBoxGrp -q -value1 stitchSrfPtsCascadeCheckBox`;
  119.     optionVar -intValue stitchSurfacePointsCascade $cascade;
  120.  
  121.     if( $doIt ) {
  122.         performStitchSurfacePoints(0); 
  123.         addToRecentCommandQueue "performStitchSurfacePoints(0)" "Stitch Surface Points";
  124.     }
  125. }
  126.  
  127. //
  128. //  Procedure Name:
  129. //      stitchSurfacePointsOptions
  130. //
  131. //  Description:
  132. //        Construct the option box UI.  Involves accessing the standard option
  133. //        box and customizing the UI accordingly.
  134. //
  135. //  Input Arguments:
  136. //      None.
  137. //
  138. //  Return Value:
  139. //      None.
  140. //
  141.  
  142. proc stitchSurfacePointsOptions()
  143. {
  144.     //    Name of the command for this option box.
  145.     //
  146.     string $commandName = "stitchSurfacePoints";
  147.  
  148.     //    Build the option box actions.
  149.     //
  150.     string $callback = ($commandName + "Callback");
  151.     string $setup = ($commandName + "Setup");
  152.  
  153.     //    Step 1:  Get the option box.
  154.     //    ============================
  155.     string $layout = getOptionBox();
  156.     setParent $layout;
  157.     
  158.     //    Step 2:  Pass the command name to the option box.
  159.     //    =================================================
  160.     setOptionBoxCommandName($commandName);
  161.     
  162.     //    Step 3:  Activate the default UI template.
  163.     //    ==========================================
  164.     setUITemplate -pushTemplate DefaultTemplate;
  165.  
  166.     //    Step 4: Create option box contents.
  167.     //    ===================================
  168.     
  169.     //    Turn on the wait cursor.
  170.     //
  171.     waitCursor -state 1;
  172.  
  173.     tabLayout -scr true -tv false;
  174.     
  175.     string $parent = `columnLayout -adjustableColumn 1`;
  176.  
  177.     setParent $parent ;
  178.     checkBoxGrp -ncb 1 -l1 "Keep Original" keepOriginalCheckBox;
  179.     checkBoxGrp -ncb 1 -l1 "Assign Equal Weights" stitchSrfPtsEqualWtsCheckBox ;
  180.     checkBoxGrp -ncb 1 -l1 "Cascade Stitch Node " stitchSrfPtsCascadeCheckBox ;
  181.  
  182.     //    Turn off the wait cursor.
  183.     //
  184.     waitCursor -state 0;
  185.     
  186.     //    Step 5: Deactivate the default UI template.
  187.     //  ===========================================
  188.     //
  189.     setUITemplate -popTemplate;
  190.  
  191.     //    Step 6: Customize the buttons.  
  192.     //    ==============================
  193.  
  194.     //    'Apply' button.
  195.     //
  196.     string $applyBtn = getOptionBoxApplyBtn();
  197.     button -edit -l "Stitch"
  198.         -command ($callback + " " + $parent + " " + 1)
  199.         $applyBtn;
  200.  
  201.     //    'Save' button.
  202.     //
  203.     string $saveBtn = getOptionBoxSaveBtn();
  204.     button -edit 
  205.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  206.         $saveBtn;
  207.  
  208.     //    'Reset' button.
  209.     //
  210.     string $resetBtn = getOptionBoxResetBtn();
  211.     button -edit 
  212.         -command ($setup + " " + $parent + " " + 1)
  213.         $resetBtn;
  214.  
  215.     //    Step 7: Set the option box title.
  216.     //    =================================
  217.     //
  218.     setOptionBoxTitle("Stitch Surface Points Options");
  219.  
  220.     //    Step 8: Customize the 'Help' menu item text.
  221.     //    ============================================
  222.     //
  223.     setOptionBoxHelpTag( "StitchSurfacePoints" );
  224.  
  225.     //    Step 9: Set the current values of the option box.
  226.     //    =================================================
  227.     //
  228.     eval (($setup + " " + $parent + " " + 0));    
  229.     
  230.     //    Step 10: Show the option box.
  231.     //    =============================
  232.     //
  233.     showOptionBox();
  234. }
  235.  
  236. //
  237. //  Procedure Name:
  238. //      stitchSurfacePointsHelp
  239. //
  240. //  Description:
  241. //        Return a short description about this command.
  242. //
  243. //  Input Arguments:
  244. //      None.
  245. //
  246. //  Return Value:
  247. //      string.
  248. //
  249.  
  250. proc string stitchSurfacePointsHelp()
  251. {
  252.     return 
  253.     "  Command: stitchSurfacePoints - stitch surface points together\n" +
  254.     "Selection: surface edit points, parameter space points";    
  255. }
  256.  
  257. //
  258. //  Procedure Name:
  259. //      assembleCmd
  260. //
  261. //  Description:
  262. //        Construct the command that will apply the option box values.
  263. //
  264. //  Input Arguments:
  265. //      None.
  266. //
  267. //  Return Value:
  268. //      None.
  269. //
  270. proc string assembleCmd()
  271. {
  272.     setOptionVars(false);
  273.  
  274.     string $cmd = "stitchSurfacePointsPreset";
  275.     $cmd = $cmd + "( " ;
  276.  
  277.     int $doHistory = `constructionHistory -q -tgl`;
  278.     $cmd = $cmd + $doHistory ;
  279.     $cmd = $cmd + ", " ;
  280.  
  281.     int $replaceOriginal = ! `optionVar -q stitchSurfacePointsKeepOriginal`;
  282.     $cmd = $cmd + $replaceOriginal ;
  283.     $cmd = $cmd + ", " ;
  284.  
  285.     int $wt = `optionVar -q stitchSurfacePointsEqualWts`;
  286.     $cmd = $cmd + $wt ;
  287.     $cmd = $cmd + ", " ;
  288.  
  289.     int $cas = `optionVar -q stitchSurfacePointsCascade`;
  290.     $cmd = $cmd + $cas ;
  291.  
  292.     $cmd = $cmd + " )" ;
  293.  
  294.     return $cmd;
  295. }
  296.  
  297. //
  298. //  Procedure Name:
  299. //      performStitchSurfacePoints
  300. //
  301. //  Description:
  302. //        Perform the stitchSurfacePoints command using the corresponding 
  303. //        option values.  This procedure will also show the option box
  304. //        window if necessary as well as construct the command string
  305. //        that will invoke the stitchSurfacePoints command with the current
  306. //        option box values.
  307. //
  308. //  Input Arguments:
  309. //      0 - Execute the command.
  310. //      1 - Show the option box dialog.
  311. //      2 - Return the command.
  312. //
  313. //  Return Value:
  314. //      None.
  315. //
  316.  
  317. global proc string performStitchSurfacePoints(int $action)
  318. {
  319.     string $cmd = "";
  320.  
  321.     switch ($action) {
  322.  
  323.         //    Execute the command.
  324.         //
  325.         case 0:
  326.             //    Get the command.
  327.             //
  328.             $cmd = `assembleCmd`;
  329.  
  330.             //    Execute the command with the option settings.
  331.             //
  332.             //    NOTE:  This following evaluation will fail because
  333.             //    this entire file exists only to serve as an example
  334.             //    for using option boxes.  There is no command called
  335.             //    'stitchSurfacePoints'.
  336.             //
  337.             eval($cmd);
  338.  
  339.             break;
  340.  
  341.         //    Show the option box.
  342.         //
  343.         case 1:
  344.             stitchSurfacePointsOptions();
  345.             break;
  346.  
  347.         //    Return the command string.
  348.         //
  349.         case 2:
  350.             //    Retrieve the option settings.
  351.             //
  352.             setOptionVars (false);
  353.  
  354.             //    Get the command.
  355.             //
  356.             $cmd = `assembleCmd`;
  357.             break;
  358.  
  359.         default :
  360.             break ;
  361.     }
  362.     return $cmd;
  363. }
  364.  
  365.